package beans;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;

/**
 * Session Bean implementation class PrimaAgain
 */
@Stateless
public class PrimaAgain implements PrimaAgainRemote {

	@Resource
	TimerService timerService;
	
	int i=500;
	@Override
	public void startTimer(Serializable info) {
		timerService.createTimer(new Date(), 1000, info);
	}

	public void stopTimer(Serializable info) {
		Timer timer = null;
		Collection<javax.ejb.Timer> timers = timerService.getTimers();
		for (Timer object : timers) {
			timer = object;
			if (timer.getInfo().equals(info)) {
				timer.cancel();
				break;
			}

		}
	}

	/**
	 * Default constructor.
	 */
	public PrimaAgain() {
	}

	@Timeout
	public void salut(Timer t) {
		System.out.println("salut");
	}

}
